<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <!-- <input  type="text" name="" id="" v-model="username">
    <input  type="text" name="" id="" v-model="userage">
    <child1 name="张云皓" age="两年半"></child1>
    <child1 :name="username" :age="userage" ></child1> -->
    <h2>蔡徐坤又要练习了，这次练习{{exercise}}年半</h2>
    <child1 @pay-exercise="exerciseHandler"></child1>

  </div>
  <template id="child1">
    <div>
      <!-- <h1> 你好啊，我是{{name}} ，我今年练习 {{age}}了</h1> -->
      <h2>{{count}}</h2>
      <button @click="count++">点击</button>
      <button @click="callTocxk">练习</button>
    </div>
  </template>

  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
 
    const app = new Vue({
      el: '#app',
      components: {
        child1: {
          template: '#child1',
          props: [],
          data() {
            return {
              count: 0
            } 
          },
          methods: {
            callTocxk() {
              this.$emit('pay-exercise',this.count)
            }
          },
        }
      },
      data: {
        username: '',
        exercise: 0

      },

      methods: {
        exerciseHandler(num) {
          this.exercise = num
        }
      }
    })

  </script>
</body>

</html>